package insight.chain.validation;

import insight.chain.exception.ValidatorException;

/**
 * @author huu
 * @create 2025-08-25-18:51
 */
public class MaxValidatorHandler implements ValidatorHandler{
    private int max;
    public MaxValidatorHandler(int max){
        this.max = max;
    }
    @Override
    public void validate(Object value, ValidatorContext context) {
        if(value instanceof Integer intValue){
            if(intValue > max){
                //throw new ValidatorException("max value is " + max);
                context.appendError("max age is " + max + ",your age " + intValue);
                //当max校验不通过不继续校验了，我需要手动控制
                //context.stopChain();
            }
            context.donext(value);
            context.put("name","huu");
        }

    }
}
